import unittest
import requests

import utils
from utils import EncryptUtil


class TestApp(unittest.TestCase):

    def test01_login(self):
        # 数据
        login_form = {
            "member_name": "13020210001",
            "password": "test123"
        }

        # # 对请求数据进行加密
        # diyou = EncryptUtil.get_diyou(login_form)
        # xmdy = EncryptUtil.get_xmdy(diyou)
        # print("diyou=====", diyou)
        # print("xmdy=====", xmdy)
        #
        # # 登录地址
        # login_url = "http://mobile-p2p-test.itheima.net/phone/member/login"
        #
        # # 发送请求
        # res_login = requests.post(url=login_url, data={"diyou": diyou, "xmdy": xmdy})
        # res_login_json = res_login.json()
        # print("登录的响应结果为：{}".format(res_login_json))
        # res_diyou = res_login_json.get("diyou")
        # print("res_diyou====", res_diyou)
        #
        # # 对响应数据进行解密
        # decrypted_data = EncryptUtil.decrypt_data(res_diyou)
        # print("res_diyou解密后====", decrypted_data)

        # 文章接口
        # agreement_url = "http://mobile-p2p-test.itheima.net/phone/articles/agreement"
        # res_article = requests.post(agreement_url, data={"diyou": diyou, "xmdy": xmdy})
        # print("获取文章的响应结果为：", res_article.text)
        # res_article_json = res_article.json()
        # print("获取文章的响应结果为：{}".format(res_article_json))
        # res_diyou = res_article_json.get("diyou")
        # print("res_diyou====", res_diyou)

        # 登录地址
        login_url = "http://mobile-p2p-test.itheima.net/phone/member/login"
        utils.send_app_requests(url=login_url,login_form=login_form)
